package com.gsj.web.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringToDateConverter implements Converter<String,Date> {
    @Override
    public Date convert(String s) {
        if(StringUtils.isEmpty(s)){
            return null;
        }else {
            try {
                return new SimpleDateFormat("yyyy-DD-mm").parse(s);
            } catch (ParseException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
    }
}
